import type { FormRules } from "naive-ui";
import { requiredRule } from "@/utils";

export const rules: FormRules = {
  type: {
    type: "number",
    ...requiredRule("请选择菜单类型"),
  },
  title: requiredRule("请输入菜单名称"),
  name: requiredRule("请输入路由名称"),
  path: requiredRule("请输入路由路径"),
  component: requiredRule("请选择菜单组件"),
  newTab: {
    type: "boolean",
    ...requiredRule("请选择打开方式"),
  },
};

export const parentMenu = ref<Menu>();

export interface MenuType {
  label: string;
  value: number;
  icon: string;
}
export const menuTypes: MenuType[] = [
  { label: "目录", value: 0, icon: "uil:folder" },
  { label: "页面", value: 1, icon: "ph:stack-bold" },
  { label: "按钮", value: 2, icon: "mdi:radiobox-marked" },
];

export const defaultFormValue = (): Menu => ({
  parentId: parentMenu.value?.id,
  type: 0,
  name: "",
  routeName: "",
  routePath: "",
  component: "",
  newTab: false,
  perms: "",
});
